home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Applications
/
TCPExample
/
PNL Libraries
/
MyCStrings.p
< prev
next >
Wrap
Text File
|
1996-11-11
|
1KB
|
70 lines
unit MyCStrings;
interface
uses
Types;
procedure CopyC2P (c: Ptr; var s: Str255);
procedure C2P(p:Ptr);
procedure CopyP2Cvar (var s:Str255; c: Ptr);
procedure CopyP2C (s:Str255; c: Ptr);
procedure P2C(p:Ptr);
implementation
uses
Memory;
procedure CopyC2P (c: Ptr; var s: Str255);
var
i,len:integer;
p,q:Ptr;
begin
len:=0;
p:=c;
while (p^<>0) & (len<255) do begin
Inc(len);
Inc(longint(p));
end;
q:=@s[len];
Dec(longint(p));
for i:=1 to len do begin
q^ := p^;
Dec(longint(q));
Dec(longint(p));
end;
q^ := len;
end;
procedure C2P(p:Ptr);
begin
CopyC2P(p,StringPtr(p)^);
end;
procedure CopyP2Cvar (var s:Str255; c: Ptr);
var
len:integer;
begin
len:=length(s);
BlockMoveData(@s[1],c,len);
Ptr(longint(c)+len)^ :=0;
end;
procedure CopyP2C (s:Str255; c: Ptr);
begin
BlockMoveData(@s[1],c,length(s));
Ptr(longint(c)+length(s))^ :=0;
end;
procedure P2C(p:Ptr);
var
len:integer;
begin
len:=BAND(p^,$00FF);
BlockMoveData(Ptr(longint(p)+1),p,len);
Ptr(longint(p)+len)^ :=0;
end;
end.